package top.drinyeit.nongmao.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import top.drinyeit.nongmao.R;
import top.drinyeit.nongmao.adapter.PaymentDetailsAdapter;
import top.drinyeit.nongmao.base.BaseActivity;
import top.drinyeit.nongmao.model.BalanceDetailBean;
import top.drinyeit.nongmao.presenter.PaymentDetailsPresenter;

/**
 * Created by bigHead on 2017/11/21.
 */

public class PaymentDetailsActivity extends BaseActivity implements View.OnClickListener {
    private ListView pay_ListView;
    private List<BalanceDetailBean> list;
    PaymentDetailsAdapter paymentDetailsAdapter;

    private PaymentDetailsPresenter paymentDetailsPresenter;

    Button bt_shouzhi_detail, bt_tixian_record;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_payment_details);

        pay_ListView = findViewById(R.id.pay_ListView);
        initViews();
        initData();

        setTitle(true, "明细");

    }

    private void initViews() {
        bt_shouzhi_detail = findViewById(R.id.bt_shouzhi_detail);
        bt_tixian_record = findViewById(R.id.bt_tixian_record);
        bt_shouzhi_detail.setOnClickListener(this);
        bt_tixian_record.setOnClickListener(this);
    }

    public void initData() {
        paymentDetailsPresenter = new PaymentDetailsPresenter(this);
        setButtonCheck(true,bt_shouzhi_detail);
        initList();
    }

    public void initList() {
        list = new ArrayList<>();
        paymentDetailsAdapter = new PaymentDetailsAdapter(this, list);
        pay_ListView.setAdapter(paymentDetailsAdapter);
        paymentDetailsPresenter.getBlDe();
    }

    public ListView getPay_ListView() {
        return pay_ListView;
    }

    public List<BalanceDetailBean> getList() {
        return list;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bt_tixian_record:
                setButtonCheck(false, view);
                getTiXianRecordData();
                break;
            case R.id.bt_shouzhi_detail:
                setButtonCheck(true, view);
                getChongZhiRecordData();
                break;
        }
    }

    private void getTiXianRecordData() {

    }

    private void getChongZhiRecordData() {

    }

    private void setButtonCheck(boolean isShouZhi, View view) {
        if (view.isSelected()) {
            return;
        }
        if (isShouZhi) {
            bt_tixian_record.setSelected(false);
            bt_shouzhi_detail.setSelected(true);
            bt_shouzhi_detail.setBackgroundDrawable(getResources().getDrawable(R.drawable.withdraw_border));
            bt_tixian_record.setBackgroundDrawable(getResources().getDrawable(R.drawable.withdraw_border_unchecked));
            bt_shouzhi_detail.setTextColor(getResources().getColor(R.color.white));
            bt_tixian_record.setTextColor(getResources().getColor(R.color.app_green));
        } else {
            bt_tixian_record.setSelected(true);
            bt_shouzhi_detail.setSelected(false);
            bt_tixian_record.setBackgroundDrawable(getResources().getDrawable(R.drawable.withdraw_border));
            bt_shouzhi_detail.setBackgroundDrawable(getResources().getDrawable(R.drawable.withdraw_border_unchecked));
            bt_tixian_record.setTextColor(getResources().getColor(R.color.white));
            bt_shouzhi_detail.setTextColor(getResources().getColor(R.color.app_green));
        }
    }
}
